<%@page import="java.util.HashMap"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="Servlets.*, java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Modify Customer</title>


  <script language="JavaScript" type="text/JavaScript">
      function isEmpty(str)
      {
          if(str == null || str == "")
              return true;
          else
              return false;
      }
 
      function validatePage()
      {
          var phone = document.getElementsByName("phone")[0].value;
          var email = document.getElementsByName("email")[0].value;
          var address = document.getElementsByName("address")[0].value;
          var city = document.getElementsByName("city")[0].value;
          var state = document.getElementsByName("state")[0].value;
          var zip = document.getElementsByName("zip")[0].value;
          
          if(isEmpty(phone))alert("Please enter phone number.");
          else if((phone.length != 10) || isNaN(phone))alert("Please enter valid phone number.");
          else if(isEmpty(email))alert("Please enter email.");
          else if(isEmpty(address))alert("Please enter address.");
          else if(isEmpty(city))alert("Please enter city.");
          else if(isEmpty(state))alert("Please enter state.");
          else if(isEmpty(zip))alert("Please enter zip code.");
          else if(isNaN(zip) || (zip.length != 5))alert("Please enter valid zip code.");
          else document.getElementById("submit").click();     
      }

      function close()
      {
    	  window.close();
      }
      </script>
        
        
</head>
<body>
<%
String[] vals = null;

if(request.getParameter("result") != null)
{
    vals = ((String)request.getParameter("result")).split("\\$");
}

%>

<CENTER>
 <form method="post" action="modifyCustomerInfo">
     <h1>Customer Info. Modification</h1>
     <table>

         <tr><td>First Name : </td>
         <td><input type="text" name="firstname" size="20" maxlength="20" disabled="disabled" value='<%=vals[1] %>' ></td> </tr>
         <tr><td>Last Name : </td>
         <td><input type="text" name="lastname" size="20" maxlength="20" disabled="disabled" value='<%=vals[2] %>' ></td></tr>
         <tr><td>Date of Birth : </td>
         <td><input type="text" name="dob" size="10" maxlength="10" disabled="disabled" value=<%=vals[9] %> ></td></tr>
         <tr><td>Phone : </td>
         <td><input type="text" name="phone" size="10" maxlength="10" value=<%=vals[5] %> ></td></tr>
         <tr><td>Email : </td>
         <td><input type="text" name="email" size="20" maxlength="80" value='<%=vals[6] %>' ></td></tr>
         <tr><td>Address : </td>
         <td><input type="text" name="address" size="20" maxlength="80" value='<%=vals[3] %>' ></td></tr>
         <tr><td>City : </td>
         <td><input type="text" name="city" size="20" maxlength="20"  value='<%=vals[4] %>' ></td></tr>
         <tr><td>State : </td>
         <td><input type="text" name="state" size="20" maxlength="20"  value='<%=vals[7] %>' ></td></tr>
         <tr><td>Zip Code : </td>
         <td><input type="text" name="zip" size="5" maxlength="5"  value=<%=vals[8] %> ></td></tr>
     </table><br><br>

     <input type="button" value="Modify Customer" onclick="validatePage();"/>
     <input type="hidden" name="modifyingCustomer" value="modifyingCustomer"/> 
     <input type="hidden" name="cid" value='<%=request.getParameter("cid")%>'/> 
     <input id="submit" type="submit" name="submit" value="submit" onclick="close();"/> 
 </form>

</CENTER>
</body>
</html>